<%--
  Created by IntelliJ IDEA.
  User: 86199
  Date: 2021/12/1
  Time: 10:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>入库</title>
    <link rel="stylesheet" href="/css/receive.css">
    <script src="/js/jquery-3.6.0.min.js"></script>
    <script type="text/javascript">
        $(function () {
            init()
        })
        function init() {
            getAll();
        }
        function getAll() {
            $.getJSON("/receive.do",{"opr":"getAll"},function (data) {
                $("tbody").empty();
                $(data.data).each(function (i,o) {
                    $("#tbody").append(
                        "<tr> " +
                        "<td width='200px'> "+
                        (i+1)+
                        "</td> <td width='400px'> " +
                        o.receiveNumber+
                        "</td> <td width='300px'>" +
                        o.goodsId+
                        "</td> <td width='200px'>"+
                        o.receiveCount+
                        "<td width='200px'> "+
                        "<a href='javascript:toUpdate("+JSON.stringify(o)+")'>修改</a>  "+
                        "<a href='javascript:deleteReceive("+JSON.stringify(o)+")'>删除</a> " +
                        "</td> </tr>");
                })
            })
        }
        function addReceive() {
            var its = $(".goodstop").serialize();
            $.getJSON("/receive.do",its,function (data) {
                if(data.code==200){
                    alert("入库单开具成功");
                    getAll();
                    window.location.href="/user/receiveDetail.jsp";
                }else {
                    alert("入库失败")
                }
            })
        }
        function deleteReceive(receive) {
            $.post("/receive.do",{"opr":"deleteReceive","rid":receive.rid},function (data) {
                if(data.code==200){
                    alert(data.message);
                    getAll();
                }
            },"json")
        }
    </script>
</head>
<body>
<div style="border: 1px solid #000000;width: 100%;height: 680px" >
    <form class="goodstop" style="width: 100%;text-align: center">
        <span>入库商品:</span> <input type="text" name="goodsId" placeholder="请输入商品编号">
        <span>入库数量:</span> <input type="text" name="receiveCount" placeholder="请输入商品数量">
        <input name="opr" value="addReceive" type="hidden">
        <button  type="button" onclick="addReceive()">入库</button>
        <button  type="button" onclick="clearText()">清空</button>
        <button  type="button" onclick="clearText()">新增</button>
        <%--<button  type="button" onclick="clearText()">导入商品</button>--%>
    </form>
    <div class="goods">
        <table style="text-align: center" id="table1">
            <thead>
            <tr>
                <th colspan="5">入库单</th>
            </tr>
            <tr><!-- 1300px -->
                <td width="200px">
                    序号
                </td>
                <td width="400px">
                    入库编号
                </td>
                <td width="300px">
                    商品编号
                </td>
                <td width="200px">
                    入库数量
                </td>
                <td width="200px">
                    操作
                </td>
            </tr>
            </thead>
            <tbody id="tbody">

            </tbody>
        </table>
    </div>
    <div class="goodspage">
        <ul id="pagination-digg" style="float: right">
            <li class="active">1</li>
            <li><a href="">2</a></li>
            <li><a href="">3</a></li>
            <li><a href="">4</a></li>
            <li><a href="">5</a></li>
            <li><a href="">6</a></li>
            <li><a href="">7</a></li>
            <li class="next"><a href="">Next &raquo;</a></li>
        </ul>
    </div>
</div>
</div>
</body>
</html>
